package com.ruoyi.core.config;

import com.gitee.deeround.jdbchelper.out.DbType;
import com.ruoyi.core.util.JsonUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@ConfigurationProperties(prefix = "config")
@Component
@Data
public class GlobalProperties {


    private String contextPath;

    private Db db;

    @PostConstruct
    public void init() {
        log.info("GlobalProperties===>{}", JsonUtil.toJson(this));
    }

    @Data
    public static class Db {
        private DbType dbType;
        private Boolean readonly;
        private Long writeMaxNum;

        public Db() {
            dbType = DbType.AUTO;
            readonly = false;
            writeMaxNum = -1L;
        }
    }

}
